package cn.hchaojie.javase.day01.exercise;

import org.junit.Test;

public class Prime {
	@Test
	public void test() {
//		System.out.println(isPrime(8));
//		System.out.println(isPrime(9));
//		System.out.println(isPrime(7));
		
//		for (int i = 2; i <= 100; i++) {
//			if (isPrime(i)) {
//				System.out.println(i);
//			}
//		}
		
		int count = 0;
		int i = 2;
		while (count < 50) {
			if (isPrime(i)) {
				System.out.println(i);
				count++;
			}
			
			i++;
		}
	}
	
	public static boolean isPrime(int number) {
		boolean flag = true;
		for (int start = 2; start < number; start++) {
			if (number % start == 0) {
				flag = false;
				break;
			}
		}
		
		return flag;
	}

	public static boolean isPrime2(int number) {
		for (int start = 2; start < number; start++) {
			if (number % start == 0) {
				return false;
			}
		}
		
		return true;
	}
}
